package org.vaadinetherealintegration.client.example2;

import etrl.geometry.Drawable;
import etrl.geometry.IndexArray;
import etrl.geometry.PrimitiveKind;
import etrl.geometry.Vertex;
import etrl.geometry.VertexArray;
import etrl.vecmath.Vector2f;
import etrl.vecmath.Vector3f;
import etrl.vecmath.Vector4f;

public class Ground extends Drawable
{
	public Ground()
	{
		  super(PrimitiveKind.TRIANGLE_STRIP);
		  
		  Vector4f color = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
		  Vector3f normal = new Vector3f(0.0f, 0.0f, 1.0f);
		  
		  Vertex v1 = new Vertex();
		  v1._coordinate = new Vector4f(-0.5f, -0.5f, 0.0f, 1.0f);
		  v1._color = color;
		  v1._normal = normal;
		  v1._texCoord = new Vector2f(0.f, 0.f);
		  
		  Vertex v2 = new Vertex();
		  v2._coordinate = new Vector4f(0.5f, -0.5f,	0.0f, 1.0f);
		  v2._color = color;
		  v2._normal = normal;
		  v2._texCoord = new Vector2f(1.f, 0.f);
		  
		  Vertex v3 = new Vertex();
		  v3._coordinate = new Vector4f(-0.5f, 0.5f, 0.0f, 1.0f);
		  v3._color = color;
		  v3._normal = normal;
		  v3._texCoord = new Vector2f(0.f, 1.f);
		  
		  Vertex v4 = new Vertex();
		  v4._coordinate = new Vector4f(0.5f, 0.5f, 0.0f, 1.0f);
		  v4._color = color;
		  v4._normal = normal;
		  v4._texCoord = new Vector2f(1.f, 1.f);
		  
		  VertexArray vertice = new VertexArray();
		  vertice.push_back(v1);
		  vertice.push_back(v2);
		  vertice.push_back(v3);
		  vertice.push_back(v4);
		    
		  IndexArray indice = new IndexArray();
		  indice.push_back(0);
		  indice.push_back(1);
		  indice.push_back(2);
		  indice.push_back(3);
		  
	      this.setVertexArray(vertice);
	      this.setIndexArray(indice);
	}
}
